COLUMN_NAME,
COLUMN_VALUE,
COLUMN_DEFINED_AT,
- COLUMN_OBJECT,
COLUMN_TOOLTIP,
COLUMN_WRITABLE,
COLUMN_ATTRIBUTE
g_free (name);
}
+static void cleanup_object (GtkInspectorPropList *pl);
+
+static void
+finalize (GObject *object)
+{
+ GtkInspectorPropList *pl = GTK_INSPECTOR_PROP_LIST (object);
+
+ cleanup_object (pl);
+ g_hash_table_unref (pl->priv->prop_iters);
+
+ G_OBJECT_CLASS (gtk_inspector_prop_list_parent_class)->finalize (object);
+}
+
static void
gtk_inspector_prop_list_class_init (GtkInspectorPropListClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ object_class->finalize = finalize;
object_class->get_property = get_property;
object_class->set_property = set_property;
COLUMN_NAME, prop->name,
COLUMN_VALUE, value ? value : "",
COLUMN_DEFINED_AT, g_type_name (prop->owner_type),
- COLUMN_OBJECT, pl->priv->object,
COLUMN_TOOLTIP, g_param_spec_get_blurb (prop),
COLUMN_WRITABLE, (prop->flags & G_PARAM_WRITABLE) != 0,
COLUMN_ATTRIBUTE, attribute ? attribute : "",
GParamSpec *prop,
GtkInspectorPropList *pl)
{
- GtkTreeIter *iter = g_hash_table_lookup (pl->priv->prop_iters, prop->name);
+ GtkTreeIter *iter;
+
+ if (!pl->priv->object)
+ return;
+ iter = g_hash_table_lookup (pl->priv->prop_iters, prop->name);
if (iter != NULL)
gtk_inspector_prop_list_update_prop (pl, iter, prop);
}
-static void remove_dead_object (gpointer data, GObject *dead_object);
-
static void
cleanup_object (GtkInspectorPropList *pl)
{
- if (pl->priv->object)
- g_object_weak_unref (pl->priv->object, remove_dead_object, pl);
-
- if (pl->priv->object && pl->priv->notify_handler_id != 0)
- {
- g_signal_handler_disconnect (pl->priv->object, pl->priv->notify_handler_id);
- pl->priv->notify_handler_id = 0;
- }
+ if (pl->priv->object &&
+ g_signal_handler_is_connected (pl->priv->object, pl->priv->notify_handler_id))
+ g_signal_handler_disconnect (pl->priv->object, pl->priv->notify_handler_id);
pl->priv->object = NULL;
+ pl->priv->notify_handler_id = 0;
g_hash_table_remove_all (pl->priv->prop_iters);
gtk_list_store_clear (pl->priv->model);
}
-static void
-remove_dead_object (gpointer data, GObject *dead_object)
-{
- GtkInspectorPropList *pl = data;
-
- pl->priv->notify_handler_id = 0;
- pl->priv->object = NULL;
- cleanup_object (pl);
-}
-
gboolean
gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
GObject *object)
cleanup_object (pl);
- pl->priv->object = object;
-
if (!object)
{
gtk_widget_hide (GTK_WIDGET (pl));
return TRUE;
}
- g_object_weak_ref (object, remove_dead_object, pl);
-
if (pl->priv->child_properties)
{
GtkWidget *parent;
props = g_object_class_list_properties (G_OBJECT_GET_CLASS (object), &num_properties);
}
+ pl->priv->object = object;
+
for (i = 0; i < num_properties; i++)
{
GParamSpec *prop = props[i];
g_hash_table_insert (pl->priv->prop_iters, (gpointer) prop->name, gtk_tree_iter_copy (&iter));
}
+ g_free (props);
+
+ if (GTK_IS_WIDGET (object))
+ g_signal_connect_swapped (object, "destroy", G_CALLBACK (cleanup_object), pl);
+
/* Listen for updates */
pl->priv->notify_handler_id =
g_signal_connect (object,
pl);
gtk_widget_show (GTK_WIDGET (pl));
+
return TRUE;
}
<column type="gchararray"/>
<column type="gchararray"/>
<column type="gchararray"/>
- <column type="GObject"/>
<column type="gchararray"/>
<column type="gboolean"/>
<column type="gchararray"/>
<object class="GtkTreeView" id="tree">
<property name="visible">True</property>
<property name="model">model</property>
- <property name="tooltip-column">4</property>
+ <property name="tooltip-column">3</property>
<property name="activate-on-single-click">True</property>
<signal name="row-activated" handler="row_activated"/>
<child>
</object>
<attributes>
<attribute name="text">0</attribute>
- <attribute name="sensitive">5</attribute>
+ <attribute name="sensitive">4</attribute>
</attributes>
</child>
</object>
</object>
<attributes>
<attribute name="text">1</attribute>
- <attribute name="sensitive">5</attribute>
+ <attribute name="sensitive">4</attribute>
</attributes>
</child>
</object>
<property name="editable">False</property>
</object>
<attributes>
- <attribute name="text">6</attribute>
- <attribute name="sensitive">5</attribute>
+ <attribute name="text">5</attribute>
+ <attribute name="sensitive">4</attribute>
</attributes>
</child>
</object>
</object>
<attributes>
<attribute name="text">2</attribute>
- <attribute name="sensitive">5</attribute>
+ <attribute name="sensitive">4</attribute>
</attributes>
</child>
</object>